<template>
  <div class="case-header-print">
    <div class="title">
      <div class="title-l">病例</div>
      <div class="title-r">门诊</div>
    </div>
    <div class="baseInfo">
      <div class="baseInfo-t">
        <div class="baseInfo-t-l">病历号：{{ caseData.ID }}</div>
        <div class="baseInfo-t-r">就诊日期：{{ caseData.created_at | dateFormat("yyyy-mm-dd HH:MM:SS") }}</div>
        <div class="baseInfo-t-r">就诊类型：{{caseData.medical_repeat==1?'初诊':'复诊'}}</div>
      </div>
      <div class="baseInfo-b">
        <div class="baseInfo-b-item">
          <span class="item-title">姓名：</span>
          <p>{{ caseData.real_name }}</p>
        </div>
        <div class="baseInfo-b-item">
          <span class="item-title">性别：</span>
          <p v-if="caseData.gender">
            {{ caseData.gender == "0" ? "男" : "女" }}
          </p>
        </div>
        <div class="baseInfo-b-item">
          <span class="item-title">年龄：</span>
          <p v-if="caseData.age"><span v-if="caseData.age[0]>0">{{ caseData.age[0] }}岁</span><span v-if="caseData.age[1]>0">{{ caseData.age[1] }}月</span><span v-if="caseData.age[2]>0">{{ caseData.age[2] }}天</span></p>
        </div>
        <div class="baseInfo-b-item">
          <span class="item-title">科室：</span>
          <p>{{ caseData.department_name }}</p>
        </div>
      </div>
    </div>
    <div class="case-info">
      <div class="info-line">
        <span>主诉/现病史：</span><span>{{ caseData.medical_describe }}</span>
      </div>
      <div class="info-line"  v-if="caseFieldData.findIndex(p=>p.name=='past_history')>-1||caseFieldData.findIndex(p=>p.name=='personal_history')>-1||caseFieldData.findIndex(p=>p.name=='allergy_history')>-1">
        <p class="line-item" v-if="caseFieldData.findIndex(p=>p.name=='past_history')>-1">
          <span>既往史：</span><span>{{ caseData.past_history }}</span>
        </p>
        <p class="line-item" v-if="caseFieldData.findIndex(p=>p.name=='personal_history')>-1">
          <span>个人史：</span><span>{{ caseData.personal_history }}</span>
        </p>
        <p class="line-item" v-if="caseFieldData.findIndex(p=>p.name=='allergy_history')>-1">
          <span>过敏史：</span><span>{{ caseData.allergy_history }}</span>
        </p>
      </div>
      <div class="info-line" v-if="caseFieldData.findIndex(p=>p.name=='tigejiancha')>-1">
        <p class="line-item">
          <span>温度：</span><span>{{ caseData.temperature?`${caseData.temperature}℃`:"" }}</span>
        </p>
        <p class="line-item">
          <span>体重：</span><span>{{ caseData.weight?`${caseData.weight}KG`:"" }}</span>
        </p>
        <p class="line-item">
          <span>心率：</span><span>{{ caseData.heart_rate?`${caseData.heart_rate}bpm`:"" }}</span>
        </p>
        <p class="line-item">
          <span>血压：</span><span>{{ caseData.blood_pressure_1?`${caseData.blood_pressure_1}mmHg`:"" }} - {{ caseData.blood_pressure_2?`${caseData.blood_pressure_2}mmHg`:"" }}</span>
        </p>
      </div>
    </div>
    <div class="result">诊断：{{ caseData.result }}</div>
    <div class="advice">医嘱：{{ caseData.advice||"无" }}</div>
  </div>
</template>
<script>
export default {
  props: {
    caseData: {
      type: Object,
      default: () => {},
    },
  },
  data(){
    return {
      caseFieldData: []
    }
  },
  created(){
    this.caseFieldData = this.caseField()
    console.log(this.caseFieldData)
  },
  methods: {
    caseField(){
      return this.$store.getters.userHabit.checkedField
    }
  }
};
</script>
<style lang="scss" scoped>
@import "@/assets/scss/print/caseHeader.scss";
</style>